<?php
class User extends AppModel
{
	var $name = "user";
	var $hasAndBelongsToMany = array(
       'Blog' =>
           array(
	           'className'              => 'Blog',
               'joinTable'              => 'blogs_users',
               'foreignKey'             => 'user_id',
               'associationForeignKey'  => 'blog_id'
           		)
       );
 	function validateLogin($data) { 
        $user = $this->find(array('username' => $data['username'], 'password' => md5($data['password'])), array('id', 'username')); 
		$emailUser = $this->find(array('email' => $data['username'], 'password' => md5($data['password'])), array('id', 'username'));
        if(empty($user) == false) {
            return $user['User']; 
		}
		if(empty($emailUser) == false) {
            return $email['User']; 
		}
        return false; 
    } 
}
?>